<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>

    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">

    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet"  th:href = "@{/css/xcConfirm.css}">
    <script th:src = "@{/js/xcConfirm.js}"></script>
    <style>
        .mytable{
            font-size: 16px;
            text-align: center;
        }
        .mytable th{
            text-align: center;
        }
    </style>
    <script>
        function getUrlParms(name){
            //获得页面url的某个url参数的方法
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)
                return unescape(r[2]);
            return null;
        }
        var id = getUrlParms("rslt");
        // console.log(id);
        if(id=="1"){
            $(function () {
                var txt=  "没有标签，请尽快添加";
                // console.log(txt);
                window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
            })
        }
        if(id=="2"){
            $(function () {
                var txt=  "删除成功";
                // console.log(txt);
                window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
            })
        }
    </script>


</head>
<body>
<br>
<br>
<table class="table  mytable table-bordered">
    <thead>
    <tr>
        <td>标题</td>
        <td>封面</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    <tr th:each="tagsList:${tagsList}">
        <td th:text="${tagsList.tag}">前端</td>
        <td >
            <img src="" alt="">
        </td>
        <td>
            <a id="deleteBtn">
                <button class="btn btn-warning" id="tagsId" th:value="${tagsList.tagid}" >取消收藏</button>
            </a>
        </td>
    </tr>
    </tbody>
</table>
<ul class="pagination">
    <li><a th:href="@{'/admin/toTagsPage?pageNum='+${currPage-1}}">&laquo;</a></li>
    <li th:each="pageNum:${pages}">
        <a th:href="@{'/admin/toTagsPage?pageNum='+${pageNum}}"th:classappend="${pageNum==currPage}?'active'"th:text="${pageNum}">1</a>
    </li>
    <li><a th:href="@{'/admin/toTagsPage?pageNum='+${currPage+1}}">&raquo;</a></li>
</ul>

<!--删除-->
<script>
    $("#deleteBtn").click(function () {
        var result = confirm("确认删除？")
        if (result){
            //删除
            var tagsId = $("#tagsId").attr("value");
            $.ajax({
                url:"[(@{/admin/deleteTag})]",
                data:{"tagsId":tagsId},
                type:"post",
                success:function (measure) {
                    if (measure == "1"){
                        //删除成功
                        $(function () {
                            var txt = "删除成功";
                            // console.log(txt);
                            window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
                        })
                        window.location.href="[(@{/admin/toTagsPage})]"
                    }
                }
            })
        }
    })
</script>

</body>
</html>